﻿CREATE PROCEDURE dbo.s_Ver_Status
	@LoanID int,
	@Statuses nvarchar(4000),
	@Checked bit
AS

DECLARE @VerID int,@Status nvarchar(4000) SET @Status = dbo.getTokenLeft(@Statuses,',')

SET @VerID =
CASE @Status
	WHEN 'TrackerRequest_Sent' THEN 86
	WHEN 'TrackerRequest_Confirmed' THEN 87
	WHEN 'TrackerRequest_Complete' THEN 88
	ELSE 0
END

IF @VerID = 0 BEGIN	RAISERROR('%s is wrong status name.',16,1,@Status) RETURN END

UPDATE t_Loan_Verification SET Checked = @Checked
WHERE (LoanID = @LoanID) AND (VerificationID = @VerID)

SET @Statuses = dbo.GetTokenRight(@Statuses,',')
IF NOT @Statuses IS NULL EXEC s_Ver_Status @LoanID,@Statuses,@Checked

--IF @Checked IS NULL RETURN (SELECT Checked FROM v_Loan_Verification WHERE LoanID = @LoanID AND VerificationID = 
